#pragma once
#include "vtkslicerwidget.h"
#include "EndoscopeLogic.h"
#include <map>
class vtkProp3D;
class vtkKWRenderWidget;
class vtkMRMLDisplayableNode;
class vtkMRMLDisplayNode;
class vtkVirtualDisplayWidget :
	public vtkSlicerWidget
{
public:
	static vtkVirtualDisplayWidget * New();
	 vtkTypeRevisionMacro(vtkVirtualDisplayWidget, vtkSlicerWidget);
	 vtkGetObjectMacro(MainViewer, vtkKWRenderWidget);
	 vtkSetObjectMacro(Logic, EndoscopeLogic);
	 vtkSetMacro (RenderPending, int);
	 vtkGetMacro (RenderPending, int);
	 void UpdateModelsFromMRML(void);
	 void UpdateModelPolyData(vtkMRMLDisplayableNode * model);
	 void UpdateModel(vtkMRMLDisplayableNode * model);
	 void SetModelDisplayProperty(vtkMRMLDisplayableNode * model);
	 vtkProp3D * GetActorByID(const char * id);
	 std::vector<vtkMRMLDisplayNode *> GetDisplayNode(vtkMRMLDisplayableNode * model);
	 void UpdateModifiedModel(vtkMRMLDisplayableNode * model);
	 void RemoveModelObservers(vtkMRMLDisplayableNode * model);
	 void RemoveModelObservers(int clearCache);
	 void ProcessMRMLEvents(vtkObject * caller, unsigned long even, void * callData);
	 void RequestRender(void);
	 void UpdateFromMRML(void);
	 void Render(void);

protected:
	void CreateWidget();
	vtkKWRenderWidget * MainViewer;
	EndoscopeLogic * Logic;	
	std::map<std::string, vtkProp3D *> DisplayedActors;
	 std::map<std::string, vtkMRMLDisplayableNode *> DisplayableNodes;
	 std::map<std::string, vtkMRMLDisplayNode *> DisplayedNodes;
	 std::map<std::string, int> DisplayedClipState;
	 std::map<std::string, int> DisplayedVisibility;
	 int ProcessingMRMLEvent;
	 int RenderPending;
	 int UpdateFromMRMLRequested;
	 int IsResetCamera;
	 bool SceneClosing;
	vtkVirtualDisplayWidget(void);
	~vtkVirtualDisplayWidget(void);
private:
	vtkVirtualDisplayWidget(const vtkVirtualDisplayWidget &);
	void operator = (const vtkVirtualDisplayWidget &);
	void ClearupActor(void);
	void RemoveDisplayable(vtkMRMLDisplayableNode * model);
	void RemoveDispalyedID(std::string & id);

	void UpdateModelImageData(vtkMRMLVolumeNode * vmodel);
};
